package day13;

/**
 * @author xinxing
 */
public class Person {

    private String name;
    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }

    public Person(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void change(Person person) {
        this.name = person.name;
        System.out.println("p change:" + this.name);
    }

    public static void main(String[] args) {

        Person p1 = new Person("123");
        Person p2 = new Person("456");

        swap(p1, p2);

        System.out.println("p1:" + p1);
        System.out.println("p2:" + p2);

        int i = 10;
        count(i);
        System.out.println("i:" + i);

        p1.change(p2);
        System.out.println("p1 change: " + p1);
    }

    private static void count(int j) {
        j = 20;
        System.out.println("j:" + j);
    }

    private static void swap(Person p1, Person p2) {
        Person p = p1;
        p1 = p2;
        p2 = p;
        System.out.println("p1:" + p1);
        System.out.println("p2:" + p2);
    }

}
